package com.GB26875_3_2011.message.parser;

import com.GB26875_3_2011.annotation.Parser;
import com.GB26875_3_2011.common.GB26875Constant;
import com.GB26875_3_2011.model.GB26875MessageBody;
import com.GB26875_3_2011.util.ByteUtils;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

import static com.GB26875_3_2011.codec.MessageDecoder.parseHexTime;

/**
 * @author 蒋仕国
 * @projectName GB26875_3_211
 * @ClassName MessageBodyParser_25
 * @date 2025-01-14 16:14
 * @Description: TODO []
 */
@Parser(unitId = 28)
public class MessageBodyParser_28 implements MessageBodyParser {
    @Override
    public GB26875MessageBody parseBody(ByteBuf buffer) {
        String timeFlagHex = ByteUtils.readSomeByteToHex(6, buffer);
        LocalDateTime localDateTime = parseHexTime(timeFlagHex, GB26875Constant.BASE_YEARS);
        return new MessageBody_28(localDateTime);
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Accessors(chain = true)
    public static class MessageBody_28 implements GB26875MessageBody {
        private LocalDateTime timeFlag;
    }
}
